package crawer.test;

import java.util.Objects;

public class Student implements Comparable<Student> {
    int number;
    String name;
    int score;

    public Student() {

    }

    public Student(int number, String name, int score) {
        this.number = number;
        this.name = name;
        this.score = score;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return number == student.number &&
                score == student.score &&
                Objects.equals(name, student.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(number, name, score);
    }

    @Override
    public String toString() {
        return number + ", " + name + ", " + score;
    }

    @Override
    public int compareTo(Student o) {
        int sort1 = o.score - this.score;
        int sort2 = sort1 == 0 ? this.number - o.number : sort1;
        return sort2;

    }
}
